//
// Created by ubuntu on 2024/1/3.
//

#ifndef LASER_LINE_FITTER_SEED_AREA_GROWTH_H
#define LASER_LINE_FITTER_SEED_AREA_GROWTH_H

#include "utils.h"

namespace line_extraction
{

class SeedAreaGrowth
{
public:
    SeedAreaGrowth();

    ~SeedAreaGrowth();

    //返回直线分割结果
    void extractLines(std::vector<line> &, std::vector<gline> &);

    Params params_;
    CSdata cs_data_;
    Rangedata range_data_;
private:
    //检测种子点，障碍物聚类的子函数
    //bool detectseed(PoinT );
    //障碍物检测，区域生长
    //int regiongrow(int);
    //通过激光数据的首末索引值进行直线方程的求解
    least leastsquare(int, int, int);

    //检测种子直线
    bool detectline(const int, const int);

    //通过种子直线，复原出整条直线，并进行最后的求定
    int detectfulline(const int);

    //整理整条直线
    void cleanline();

    //删除小于长度阈值的线段
    bool delete_short_line(const int, const int);

    void generate(std::vector<gline> &temp_line2);

    std::vector<unsigned int> point_num_;
    //线段结构体信息
    std::vector<line> m_line;
    //直线拟合中间传递变量，已设为全局变量
    least m_least;
    //拟合中间变量
    double mid1;
    double mid2;
    double mid3;
    double mid4;
    double mid5;
};


}

#endif //LASER_LINE_FITTER_SEED_AREA_GROWTH_H
